package com.szss.springbootfirst.controller;

import com.szss.springbootfirst.entity.User;
import com.szss.springbootfirst.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author wcx
 * @date 2023/2/1 16:51
 */

@Controller
public class LoginController {

    @Autowired
    private IUserService userService;

    @RequestMapping("/")
    public String face(){
        return "login";
    }

    @RequestMapping("/login")
    public String login(User user){
        User resultUser = userService.login(user);
        if (resultUser != null){
            return "redirect:/index";
        }
        return "login";
    }
}
